﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml.Serialization;
using System.Xml;

namespace Abhimanu.Mobile.Utility
{
    public class Common
    {
        public static string SerializeObject(QuestionBank input)
        {
            XmlSerializer ser = new XmlSerializer(input.GetType());
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            System.IO.StringWriter writer = new System.IO.StringWriter(sb);
            ser.Serialize(writer, input);
            return sb.ToString();
        }

        public static QuestionBank DeserializeString(string input)
        {
            QuestionBank result = new QuestionBank();
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(input);
            XmlNodeReader reader = new XmlNodeReader(doc.DocumentElement);
            XmlSerializer ser = new XmlSerializer(result.GetType());
            object obj = ser.Deserialize(reader);
            return (QuestionBank)obj;
        }
    }
}